<html xmlns="http://www.w3.org/1999/xhtml"  
    xmlns:h="http://java.sun.com/jsf/html"  
    xmlns:f="http://java.sun.com/jsf/core"  
    xmlns:p="http://primefaces.org/ui"> 
<h:head>
	<title>Página de Edição</title>
</h:head> 
<h:body> 
<center>


<h:form>	
		<p:panel header="Atualização de Clientes" style="width: 400px;">
			<p:messages id="messages"/>
			<p:panelGrid columns="2" >
				<h:outputText value="CPF: *" />
				<p:inputText id="cpf" value="#{clienteBean.cliente.cpf}" required="true" requiredMessage="Insira o CPF">
					<f:validateLength minimum="6" maximum="11"  />
				</p:inputText>
				
				<h:outputText value="E-Mail: *" />
				<p:inputText id="email" value="#{clienteBean.cliente.email}" required="true" requiredMessage="Insira o E-Mail">
					<f:validateLength minimum="4" />
				</p:inputText>
			</p:panelGrid>
			
			<p:commandButton action="#{clienteBean.adicionarCliente}" value="Cadastrar"/>
		</p:panel>
</h:form>


<p:panel>	
	<h:form>
		<p:panel header="Atualização de Clientes" style="width: 400px;">
			 <p:messages id="messages"/> 
			<p:panelGrid columns="2">
				CPF: <h:inputText id="cpf" value="#{clienteBean.cliente.cpf}"  required="true" requiredMessage="Por favor insira o CPF!"/>
				E-Mail: <h:inputText id="email" value="#{clienteBean.cliente.email}" required="true" requiredMessage="Por favor insira o E-Mail!"/>
				<h:inputHidden /><h:inputHidden />
				<h:commandButton type="reset" value="Limpar" />
				<h:commandButton type="buttom" action="#{clienteBean.adicionarCliente}" value="Cadastrar" styleClass="ui-priority-primary" />
			</p:panelGrid>
		</p:panel>
	</h:form>
</p:panel>

<p:panel>
	<h:form>
		<p:panel header="Lista de Clientes Cadastrados">
			<h:dataTable value="#{clienteBean.listarClientes()}" cellspacing="5" cellpadding="1" var="clientes" border="1" id="tabela">			
				<p:column>
					<f:facet name="header">
						ID
					</f:facet>
					<h:outputText value="#{clientes.id}" />
				</p:column>
				
				<p:column>
					<f:facet name="header">
						CPF
					</f:facet>
					<h:outputText value="#{clientes.cpf}" />
				</p:column>
				
				<p:column>
					<f:facet name="header">
						E-Mail
					</f:facet>
					<h:outputText value="#{clientes.email}" />
				</p:column>
					
				<p:column>
					<f:facet name="header">
						Ações
					</f:facet>
					<h:commandButton action="#{clienteBean.removerClientes(clientes)}" value="Remover" />	
					| <h:commandButton action="#{clienteBean.carregarCliente(clientes)}" value="Atualizar" />			
				</p:column>				
			</h:dataTable>
		</p:panel>
	</h:form>
</p:panel>
</center>
</h:body> 
</html>
